from selenium import webdriver
from selenium.webdriver.common.by import By
import time

#需要自己先手动注册一个账号
my_username = '17788559601'
my_password = 'Roottoor@2'

# 1. 打开网站
driver = webdriver.Chrome()
driver.get("https://www.epubit.com/")

# 2. 点击登录
login_btn = driver.find_element(By.XPATH, '//i[text()="登录"]')
login_btn.click()

# 3. 输入账号密码
input_username = driver.find_element(By.XPATH, '//input[@id="username"]')
input_username.send_keys(my_username)

input_password = driver.find_element(By.XPATH, '//input[@id="password"]')
input_password.send_keys(my_password)

# 4. 提交登录
submit_btn = driver.find_element(By.XPATH, '//input[@id="passwordLoginBtn"]')
submit_btn.click()

# 5. 打印课程列表
driver.get('https://www.epubit.com/course')
time.sleep(3)
item_list = driver.find_elements_by_css_selector('.course-list a')
for item in item_list:
    print(item.text)
